package com.shujia.mr.clazzSort;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ClazzSortMapper extends Mapper<LongWritable, Text,Text,Text> {
    /*
        数据处理逻辑：
            1.读取ReduceJoin中的数据
            2.对数据进行切分，将班级作为Key,其他数据作为Value写出
     */

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context) throws IOException, InterruptedException {
//        super.map(key, value, context);

        // 1500100001	施笑槐,22,女,文科六班,406
        String[] split = value.toString().split("\t");
        String[] cols = split[1].split(",");
        String clazz = cols[3];

        // 将clazz作为Key 整个学生数据作为Value写出
        context.write(new Text(clazz),value);

    }
}
